The Numbers.app reopens the last edited document when the app launches.
If the document was moved to another folder in the Files.app while the app was not running, Numbers.app correctly tracks the file and reopens it.
However, if the document was deleted in the Files.app and moved to Recently Deleted, Numbers.app does not reopen the document when the app launches.
Question :
How does Numbers.app detect that a document has been moved to Recently Deleted?
Can third-party apps implement the same behavior?
What I tested :
If a file is moved while the app is not running, resolving a bookmark successfully tracks the moved file.
Files that are deleted via the Files.app appear in Recently Deleted, but those files are actually moved to the following directories:
iCloud Drive
/var/mobile/Library/Mobile Documents/.Trash/
On My iPad
/var/mobile/Containers/Shared/AppGroup/{UUID}/File Provider Storage/.Trash/
App sandbox Documents directory ([On My iPad]/[Any App])
/var/mobile/Containers/Data/Application/{UUID}/Documents/.Trash/
When resolving the bookmark after deletion, the bookmark still resolves successfully and returns the new file URL inside the .Trash directory.
I tried the following checks on the resolved URL:
Checking file existence
Checking read/write accessibility
Inspecting bookmark resolution results
Using APIs related to NSTrashDirectory
See https://developer.apple.com/forums/thread/813329#813329021
All of these behaved the same as when the file was moved to a normal directory. None of these checks allowed me to detect that the file had been deleted.
Additional experiment:
I suspected that the app might simply check whether the path contains ".Trash", so I performed the following experiment.
If a .numbers file is moved to
/var/mobile/Containers/Data/Application/{UUID}/Documents/.Trash/
then
The file appears in Recently Deleted in Files.app
Numbers.app does not reopen the document when the app launches
However, if the same file is moved to
Documents/Trash
Documents/.Trashed
Documents/Any Folder/.Trash
then
The file does not appear in Recently Deleted in Files
Numbers does reopen the document when launched
This suggests that Numbers.app is not simply checking whether the path contains ".Trash".
2
0
85